package com.hsomandroidapp;

import android.app.Application;
import android.content.SharedPreferences;
import android.os.Environment;

public class HsomApplication extends Application {
	public String cachePath;
	private SharedPreferences prefs;
	public static final String PREFERENCES_NAME = "HSOM";
	public static final String PREFERENCES_CREATE_CACHEPATH="cachepath";

	
	public void onCreate() {
		prefs = getSharedPreferences(PREFERENCES_NAME, 0);
		if (!prefs.getBoolean(PREFERENCES_CREATE_CACHEPATH, false)) {
			initCachePath();
		}
		super.onCreate();
	}
	
	private void initCachePath() {
		if (Environment.getExternalStorageState().equals(
				android.os.Environment.MEDIA_MOUNTED)) {
			cachePath = Environment.getExternalStorageDirectory()
					+ "/"+PREFERENCES_NAME+"/cache";
		} else {
			cachePath = this.getApplicationContext().getCacheDir().getParent()
					+  "/"+PREFERENCES_NAME+"/cache";
		}
		
	}
}
